package com.zzvcom.persist.model.admin;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import com.googlecode.jsonplugin.annotations.JSON;
import com.zzvcom.persist.model.IdEntity;

@Entity
@Table(name = "sysmodule")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class SysModule extends IdEntity
{
	private String name;

	private int seq;
	
	private String url;

	private String parentid;

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "parentid", insertable = false, updatable = false, nullable = true)
	private SysModule parent;
	
	@OneToMany(cascade = CascadeType.REMOVE, fetch = FetchType.LAZY, mappedBy = "parent")
	private Set <SysModule> children =new HashSet<SysModule>();

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public int getSeq()
	{
		return seq;
	}

	public void setSeq(int seq)
	{
		this.seq = seq;
	}

	public String getParentid()
	{
		return parentid;
	}

	public void setParentid(String parentid)
	{
		this.parentid = parentid;
	}

	public SysModule getParent()
	{
		return parent;
	}

	public void setParent(SysModule parent)
	{
		this.parent = parent;
	}

    public String getUrl()
    {
        return url;
    }

    public void setUrl(String url)
    {
        this.url = url;
    }
    @JSON(serialize=false)
	public Set<SysModule> getChildren()
	{
		return children;
	}
    @JSON(deserialize=false)
	public void setChildren(Set<SysModule> children)
	{
		this.children = children;
	}
    
    

}
